//
//  SceneryOrderRequest.m
//  LocalTravel
//
//  Created by zheng ji on 14-3-23.
//  Copyright (c) 2014年 jxw. All rights reserved.
//

#import "SceneryOrderRequest.h"
@interface SceneryOrderRequest()
{

}
@end
//景点订单
@implementation SceneryOrderRequest

/**
 提交订单，返回空表示成功，否则返回错误信息
 */
+(NSDictionary*)submitOrder:(NSDictionary*)dictInfo{
    NSString* serviceName=@"SubmitSceneryOrder";
    
    NSString* sceneryId=[dictInfo objectForKey:@"sceneryId"];
    
    NSString* bMan=[dictInfo objectForKey:@"bMan"];
    NSString* bMobile=[dictInfo objectForKey:@"bMobile"];
   // NSString* tName=[dictInfo objectForKey:@"tName"];
    //NSString* tMobile=[dictInfo objectForKey:@"tMobile"];
    NSString* policyId=[dictInfo objectForKey:@"policyId"];
    
    NSString* tickets=[dictInfo objectForKey:@"tickets"];
    NSString* travelDate=[dictInfo objectForKey:@"travelDate"];
    NSString* orderIP=[dictInfo objectForKey:@"orderIP"];
    NSString* idCard=[dictInfo objectForKey:@"idCard"];
    
    NSMutableString* stringBuffer=[[NSMutableString alloc]init];
    
    if(sceneryId==nil || [sceneryId isEqualToString:@""]){
        [stringBuffer appendFormat:@"景点ID不能为空！"];
    }
    if(bMan==nil || [bMan isEqualToString:@""]){
        [stringBuffer appendFormat:@"预订人不能为空！"];
    }
    if(bMobile==nil || [bMobile isEqualToString:@""]){
        [stringBuffer appendFormat:@"手机号码不能为空！"];
    }
    if(policyId==nil || [policyId isEqualToString:@""]){
        [stringBuffer appendFormat:@"预订的门票不能为空！"];
    }
    
    if(tickets==nil || [tickets isEqualToString:@""]){
        [stringBuffer appendFormat:@"门票张数不能为空！"];
    }
    
    if(travelDate==nil || [travelDate isEqualToString:@""]){
        [stringBuffer appendFormat:@"游玩日期不能为空！"];
    }
    if(orderIP==nil || [orderIP isEqualToString:@""]){
        orderIP=[LocalTravelConfig getClientIPForTongCheng];
    }

    
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    [requestXml appendFormat:@"<sceneryId>%@</sceneryId>",sceneryId];
    [requestXml appendFormat:@"<bMan>%@</bMan>",bMan];
    [requestXml appendFormat:@"<bMobile>%@</bMobile>",bMobile];
    [requestXml appendFormat:@"<tName>%@</tName>",bMan];
    [requestXml appendFormat:@"<tMobile>%@</tMobile>",bMobile];
    [requestXml appendFormat:@"<policyId>%@</policyId>",policyId];
    [requestXml appendFormat:@"<tickets>%@</tickets>",tickets];
    [requestXml appendFormat:@"<travelDate>%@</travelDate>",travelDate];
   
    [requestXml appendFormat:@"<orderIP>%@</orderIP>",orderIP];
    if(idCard !=nil && ![idCard isEqualToString:@""]){
       [requestXml appendFormat:@"<idCard>%@</idCard>",idCard];
    }
    
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    NSString *responseXml = [self sendRequest:requestXml tongChengUrl:[LocalTravelConfig getTongChenSceneryOrderUrl]];
    
    SceneryOrderResponseParse *parse=[[SceneryOrderResponseParse alloc]initWithXmlData:responseXml];
   
    return  [parse getResponse];
    

}



@end
